
%This graph program is the replication code for Figure 3, based on
%simulations of Simulate_Concentration_HighOLNSDF_func.m. The variable o
%represents fixed costs (in place of "m" used in the paper, which is used for other purposes in the simulation program).
% The fixed-to-marginal cost ratio is hence given by o/h, where h is parameterized in the simulation program.

clear;
clc;
close all;

set(groot,'defaulttextinterpreter','latex');
set(groot,'defaultAxesTickLabelInterpreter','latex');
set(groot,'defaultLegendInterpreter','latex');


%% Color Scheme
co = [   0    0.4470    0.7410;
    0.8500    0.3250    0.0980;
    0.9290    0.6940    0.1250;
    0.4940    0.1840    0.5560;
    0.4660    0.6740    0.1880;
    0.3010    0.7450    0.9330;
    0.6350    0.0780    0.1840];

co2 = [   0         0    1.0000;
    0    0.5000         0;
    1.0000         0         0;
    0    0.7500    0.7500;
    0.7500         0    0.7500;
    0.7500    0.7500         0;
    0.2500    0.2500    0.2500];

variable_N = 2:1:8;
variable_o = 5.5:0.1:7;





for j = 1:length(variable_N)
    for k = 1:length(variable_o)
        o_rp(j,k) = Simulate_Concentration_HighOLNSDF_func(variable_N(j), variable_o(k)); 
        n_o_graph(j,k) = variable_N(j);
        o_graph(j,k) = variable_o(k);
        oh_graph(j,k) = variable_o(k)/0.5;
    end
end


%------------------------variable N and o------------------------------
%Dropping few cases that generate negative rp
rp = o_rp;
rp(rp<0) = nan;


clc;
surf(n_o_graph,oh_graph,100*rp);
zlabel('Mean Return (%)', 'interpreter', 'latex')
xlabel('Number of Firms', 'interpreter', 'latex')
ylabel('Fixed-to-Marginal Cost Ratio', 'interpreter', 'latex')
set(gca,'FontSize',15)
set(gcf, 'Position', [300 300 1200 540])


%for jpeg
f = gcf;
set(f, 'Position', [300   222   818   557]);
ax = gca;
ax.YLabel.Rotation = 341;
ax.XLabel.Rotation = 13;
exportgraphics(f,strcat('Figure',num2str(3),'.jpg'),'BackgroundColor','none')








